<route lang="json5">
{
  layout: 'default',
  style: {
    navigationBarTitleText: '任务中心',
    enablePullDownRefresh: false,
    navigationStyle: 'custom',
  },
}
</route>

<template>
  <page-meta :root-font-size="setting.rootFontSize"></page-meta>
  <view style="display: flex; height: 100vh; flex-direction: column; background-color: #f2f2f1">
    <view style="position: sticky; top: 0; z-index: 9999">
      <wd-navbar title="任务中心详情" :bordered="false" safeAreaInsetTop>
        <template #left>
          <wd-icon name="thin-arrow-left" size="22px" color="white" @click="goBack"></wd-icon>
        </template>
      </wd-navbar>
    </view>
    <view style="flex: 1; overflow: auto">
      <th-card title="需求单信息">
        <!--  -->
        <!-- <template v-slot:titleRight>
            <view class="icon" @click.stop.prevent="showCommonMore = !showCommonMore">
              <wd-icon v-if="!showCommonMore" name="caret-down-small" size="22px"></wd-icon>
              <wd-icon v-else name="caret-up-small" size="22px"></wd-icon>
            </view>
          </template> -->
        <th-form>
          <th-form-item label="需求产品">
            <text class="text">{{ form.invName }}</text>
          </th-form-item>

          <th-form-item label="产品规格">
            <text class="text">{{ form.invStd }}</text>
          </th-form-item>
          <th-form-item label="用途" v-if="form.rdDemandEntity && form.rdDemandEntity.cusFlag != 3">
            <text class="text">{{ form.applicationType }}</text>
          </th-form-item>
          <th-form-item label="要求完成时间">
            <text class="text">{{ formatByDayjs(form.askCompleteTime) }}</text>
          </th-form-item>
          <th-form-item label="附件">
            <view class="info-list">
              <view style="display: flex; flex-direction: column">
                <view
                  v-for="file in form.rdDemandFileEntity"
                  :key="file.id"
                  style="color: #409eff"
                  @click="previewFileHandle(file.fileUrl)"
                  class="info-row-item info_row_i"
                >
                  {{ file.fileName }}
                </view>
              </view>
            </view>
          </th-form-item>
          <template v-if="showCommonMore">
            <th-form-item label="单据编号">
              <text class="text">{{ form.demandCode }}</text>
            </th-form-item>
            <th-form-item label="是否有外来样">
              <text class="text">{{ form.sampleFlagName }}</text>
            </th-form-item>
            <th-form-item label="日期">
              <text class="text">{{ formatByDayjs(form.demandDate) }}</text>
            </th-form-item>
            <th-form-item label="客户" v-if="form.cusFlag == '0'">
              <text class="text">{{ form.cusCode }}</text>
            </th-form-item>
            <th-form-item label="供应商" v-if="form.cusFlag == '3'">
              <text class="text">{{ form.cusCode }}</text>
            </th-form-item>
            <th-form-item :label="form.cusFlag == '0' ? '业务员' : '需求人'">
              <text class="text">{{ form.personName }}</text>
            </th-form-item>
            <th-form-item label="业务部门">
              <text class="text">{{ form.deptName }}</text>
            </th-form-item>
            <th-form-item label="所属公司" v-if="form.cusFlag != '1'">
              <text class="text seq-no-text">
                {{ (form.rdDemandEntity && form.rdDemandEntity.tenantName) || '' }}
              </text>
            </th-form-item>
            <th-form-item label="需求类型">
              <text class="text">{{ form.demandType }}</text>
            </th-form-item>
            <!-- <th-form-item label="指标" v-if="isShowCheckTarget" class="form-CheckTarget">
              <wd-table :data="checkTargetList">
                <wd-table-col prop="cchkguidename" label="检验指标名称" width="33%"></wd-table-col>
                <wd-table-col prop="checktarget" label="U8指标" width="33%"></wd-table-col>
                <wd-table-col prop="cusCheckTarget" label="客户指标" width="34%"></wd-table-col>
              </wd-table>
            </th-form-item> -->

            <th-form-item
              label="年需求量/吨"
              v-if="form.rdDemandEntity && form.rdDemandEntity.cusFlag != 3"
            >
              <text class="text">{{ form.invDemand }}</text>
            </th-form-item>
            <th-form-item label="样品编码" v-if="form.sampleFlag != '0'">
              <text class="text">{{ form.sampleCode }}</text>
            </th-form-item>
            <th-form-item label="需求样品数量" v-if="form.sampleFlag != '0'">
              <text class="text">{{ form.samplesNum }}{{ form.sampleUnit }}</text>
            </th-form-item>
            <th-form-item label="来样批次" v-if="form.sampleFlag != '0'">
              <text class="text">{{ form.sampleBatch }}</text>
            </th-form-item>

            <th-form-item label="是否提供样品" v-if="form.requestFlag == '1'">
              <text class="text">{{ form.requestFlag == '1' ? '是' : '否' }}</text>
            </th-form-item>
            <th-form-item label="提供样品数量" v-if="form.requestFlag == '1'">
              <text class="text">
                {{ (form.rdDemandEntity && form.rdDemandEntity.requestNum) || ''
                }}{{ (form.rdDemandEntity && form.rdDemandEntity.requestNumUnit) || '' }}
              </text>
            </th-form-item>
            <th-form-item
              label="样品验证目的"
              v-if="form.rdDemandEntity && form.rdDemandEntity.cusFlag == '3'"
            >
              <text class="text">
                {{ form.rdDemandEntity && form.rdDemandEntity.samplePurpose }}
              </text>
            </th-form-item>
            <th-form-item
              label="其他描述"
              v-if="
                form.rdDemandEntity && form.rdDemandEntity.cusFlag == '3' && form.samplePurposeDesc
              "
            >
              <text class="text">{{ form.samplePurposeDesc }}</text>
            </th-form-item>

            <!-- </th-form>
        </th-card>
        <th-card title="基本信息">
          <th-form>
            <th-form-item label="任务编号" class="form-demandDesc">
              <text class="text">{{ form.rdDemandEntity && form.rdDemandEntity.wayName }}</text>
            </th-form-item> -->
            <th-form-item label="任务" class="form-demandDesc">
              <text class="text">{{ form.rdDemandEntity && form.rdDemandEntity.wayName }}</text>
            </th-form-item>

            <th-form-item label="评审状态">
              <text class="text">
                <view
                  v-if="form.rdDemandEntity && form.rdDemandEntity.rdFlag == '1'"
                  class="result-tag"
                >
                  通过
                </view>
                <view
                  v-else-if="form.rdDemandEntity && form.rdDemandEntity.rdFlag == '0'"
                  class="result-tag"
                  style="background-color: #f50"
                >
                  不通过
                </view>
              </text>
            </th-form-item>
          </template>

          <th-form-item label="需求描述" class="form-demandDesc">
            <text class="text">{{ form.rdDemandEntity && form.rdDemandEntity.demandDesc }}</text>
          </th-form-item>
          <th-form-item label="需求评审结论" class="form-demandDesc">
            <text class="text">
              {{ form.rdDemandEntity && form.rdDemandEntity.reviewConclusion }}
            </text>
          </th-form-item>

          <!-- <th-form-item label="预计完成时间">
            <text class="text">{{ formatByDayjs(form.completeTime) }}</text>
          </th-form-item> -->

          <!-- <th-form-item label="技术负责人">
              <text class="text">{{ form.technologyHeadName }}</text>
            </th-form-item> -->
          <!-- <th-form-item
              v-for="item in rdProjectUserList.filter((item) => item.chooseFlag == 1)"
              :label="item.documentsPostName"
              :key="item.id"
            >
              <text class="text">{{ getProjectName(item) }}</text>
            </th-form-item> -->
          <!-- <th-form-item label="项目成员" class="form-demandDesc">
              <text class="text">{{ getProjectName({ documentsPostCode: 0 }) }}</text>
            </th-form-item> -->

          <!-- <th-form-item label="备注">
            <text class="text">{{ form.remark }}</text>
          </th-form-item> -->
        </th-form>

        <view class="exportModel" @click="showCommonMore = !showCommonMore">
          <text>{{ showCommonMore ? '收起' : '展开' }}</text>
        </view>
      </th-card>
      <th-card
        title="子任务记录"
        v-if="form.rdTaskListAll && form.rdTaskListAll.length && taskTypeList.includes('10')"
      >
        <wd-collapse v-model="rdTaskListAllActiveKey">
          <wd-collapse-item
            v-for="item in form.rdTaskListAll"
            :key="item.id"
            :name="item.id"
            :title="item.title"
            :before-expend="beforeExpend"
            custom-class="custom-class-collapse"
          >
            <view>
              <view v-if="item.taskType == '3'">
                <information :ref="($event) => setItemRef($event, item.taskCode)"></information>
              </view>
              <view
                v-if="item.taskType == '2' || item.taskType == '12'"
                style="max-height: 400px; overflow-y: auto"
              >
                <sampleAnalysisze
                  :ref="($event) => setItemRef($event, item.taskCode)"
                ></sampleAnalysisze>
              </view>
              <view v-if="item.taskType == '4'">
                <questionForm :ref="($event) => setItemRef($event, item.taskCode)"></questionForm>
              </view>
              <view v-if="item.taskType == '9'">
                <otherForm :ref="($event) => setItemRef($event, item.taskCode)"></otherForm>
              </view>
              <view v-if="item.taskType == '7'">
                <attenuationForm
                  :ref="($event) => setItemRef($event, item.taskCode)"
                ></attenuationForm>
              </view>
              <view v-if="item.taskType == '30'">
                <directSampleForm
                  :ref="($event) => setItemRef($event, item.taskCode)"
                ></directSampleForm>
              </view>
            </view>
          </wd-collapse-item>
        </wd-collapse>
      </th-card>

      <th-card title="任务单信息">
        <!-- <th-form> -->
        <th-form-item label="任务单编号">
          <text class="text">{{ form.taskCode }}</text>
        </th-form-item>
        <!-- <th-form-item label="任务编码">
            <text class="text">{{ form.projectCode }}</text>
          </th-form-item> -->
        <th-form-item label="任务名称">
          <text class="text">{{ form.projectName }}</text>
        </th-form-item>
        <!-- <th-form-item label="项目负责人">
            <text class="text">{{ form.projectHeadName }}</text>
          </th-form-item> -->
        <th-form-item
          label="预计完成日期"
          v-if="form.rdDemandEntity && form.rdDemandEntity.estimatedCompletionTime"
        >
          <!-- <text class="text">{{ formatByDayjs(form.userTime) }}</text> -->
          <text class="text">{{ formatByDayjs(form.rdDemandEntity.estimatedCompletionTime) }}</text>
        </th-form-item>
        <!-- <th-form-item label="技术负责人">
            <text class="text">{{ form.technologyHeadName }}</text>
          </th-form-item> -->
        <th-form-item label="研发方案" class="form-demandDesc" v-if="form.rdPlan">
          <text class="text">{{ form.rdPlan }}</text>
        </th-form-item>
        <!-- <th-form-item label="任务负责任人">
            <text class="text">{{ form.technologyHeadName }}</text>
          </th-form-item>
          <th-form-item label="任务成员">
            <text class="text">{{ form.taskUser }}</text>
          </th-form-item> -->
        <!--<th-form-item label="签收人">
            <text class="text">{{ form.signedName }}</text>
          </th-form-item> -->

        <!-- v-for="item in rdProjectUserList.filter(
              (item) => item.chooseFlag == 1 && item.documentsPostCode != '0',
            )" -->
        <th-form-item
          v-for="item in rdProjectUserList.filter(
            (item) =>
              item.chooseFlag == 1 &&
              (item.documentsPostCode == '0' || item.documentsPostCode == '2'),
          )"
          :label="item.documentsPostName"
          :key="item.id"
        >
          <text class="text">{{ getProjectName(item, 0, false) }}</text>
        </th-form-item>
        <!-- <th-form-item label="项目成员" class="form-demandDesc">
            <text class="text">{{ getProjectName({ documentsPostCode: 0 }) }}</text>
          </th-form-item> -->
        <!-- <th-form-item
            label="资料收集"
            style="flex-direction: column; align-items: start"
            v-if="form.rdInformationDTO && form.rdInformationDTO.length"
          >
            <view class="info-list">
              <view v-for="item in form.rdInformationDTO" :key="item.id" class="info-list-main">
                <view class="info-list-row">
                  <view class="info-list-label">资料名称</view>
                  <view class="info-list-value">{{ item.informationName }}</view>
                </view>
                <view class="info-list-row">
                  <view class="info-list-label">资料描述</view>
                  <view class="info-list-value">{{ item.informationDesc }}</view>
                </view>
                <view
                  class="info-list-row"
                  v-if="item.rdInformationProfileEntity && item.rdInformationProfileEntity.length"
                >
                  <view class="info-list-label">附件</view>
                  <view class="info-list-value">
                    <view style="display: flex; flex-direction: column">
                      <view
                        v-for="file in item.rdInformationProfileEntity"
                        :key="file.id"
                        @click="previewFileHandle(file.profileUrl)"
                        class="info-row-item"
                      >
                        {{ file.profileInfo }}
                      </view>
                    </view>
                  </view>
                </view>
                <view class="info-list-row">
                  <view class="info-list-label">网址</view>
                  <view
                    class="info-list-value info-row-item"
                    @click="previewWeb(item.informationWeb)"
                  >
                    {{ item.informationWeb }}
                  </view>
                </view>
              </view>
            </view>
          </th-form-item> -->
        <th-form-item
          label="合成工艺路线"
          style="flex-direction: column; align-items: start"
          v-if="form.rdCraftEntity && form.rdCraftEntity.length && taskTypeList.includes('10')"
        >
          <view class="info-list">
            <view v-for="item in form.rdCraftEntity" :key="item.id" class="info-list-main">
              <view class="info-list-row">
                <view class="info-list-label">名称</view>
                <view class="info-list-value">{{ item.craftName }}</view>
                <view v-if="item.delFlag == 1">
                  <wd-tag plain bg-color="red" color="red">废弃</wd-tag>
                </view>
              </view>

              <view class="info-list-row">
                <view class="info-list-label">反应条件</view>
                <view class="info-list-value">{{ item.craftDesc }}</view>
              </view>

              <view class="info-list-row" v-if="item.craftUrl">
                <view class="info-list-label">路线</view>
                <view class="info-list-value">
                  <wd-img
                    :width="140"
                    :height="140"
                    :src="item.craftUrl"
                    mode="aspectFit"
                    :enable-preview="true"
                  />
                </view>
              </view>

              <view class="info-list-row">
                <view class="info-list-label">是否选择</view>
                <view class="info-list-value">
                  <wd-switch
                    disabled
                    v-model="item.isUse"
                    :active-value="1"
                    :inactive-value="0"
                    style="margin: 5rpx 0"
                    size="small"
                  ></wd-switch>
                </view>
              </view>
            </view>
          </view>
        </th-form-item>

        <th-form-item
          label="附件"
          style="flex-direction: column; align-items: start"
          v-if="
            form.rdTaskFileEntity && form.rdTaskFileEntity.length && taskTypeList.includes('10')
          "
        >
          <view class="info-list">
            <view class="info-list-main">
              <view class="info-list-row">
                <!-- <view class="info-list-label">附件</view> -->
                <view class="info-list-value">
                  <view style="display: flex; flex-direction: column">
                    <view
                      v-for="file in form.rdTaskFileEntity"
                      :key="file.id"
                      @click="previewFileHandle(file.fileUrl)"
                      class="info-row-item"
                    >
                      {{ file.fileName }}
                    </view>
                  </view>
                </view>
              </view>
            </view>
          </view>
        </th-form-item>

        <!--
          <template v-if="form.taskType == '2'">
            <th-form-item
              label="分析手段"
              v-if="form.rdSampleAnalysisEntity && form.rdSampleAnalysisEntity.length"
            >
              <text class="text">
                <view style="display: flex; flex-wrap: wrap">
                  <view
                    v-for="item in form.rdSampleAnalysisEntity"
                    :key="item.id"
                    class="result-tag"
                    style="margin-right: 10rpx; background-color: #4d80f0"
                  >
                    {{ item.analysisName }}
                  </view>
                </view>
              </text>
            </th-form-item>
            <view
              style="overflow: auto"
              class="table-container"
              v-if="form.rdSampleAnalysisEntity && form.rdSampleAnalysisEntity.length"
            >
              <table class="analysis-table">
                <tbody>
                  <tr>
                    <th style="width: 320rpx; min-width: 9.5rem">名称</th>
                    <th style="width: 280rpx; min-width: 280rpx">说明</th>
                  </tr>
                  <tr
                    align="center"
                    v-for="(item, index) in form.rdSampleAnalysisEntity"
                    :key="index"
                  >
                    <td>
                      <view>
                        {{ item.analysisName }}
                      </view>
                    </td>
                    <td>
                      <view>
                        {{ item.analysisDesc }}
                      </view>
                    </td>
                  </tr>
                </tbody>
              </table>
            </view>
            <th-card title="外来样报检报告">
              <assayReport :pid="form.id" :version="1"></assayReport>
            </th-card>
          </template> -->

        <!-- <th-form-item label="综述" class="form-demandDesc" v-if="form.sampleReviewConclusion">
            <text class="text">{{ form.sampleReviewConclusion }}</text>
          </th-form-item> -->

        <!-- <th-form-item label="其他内容" class="form-demandDesc" v-if="form.others">
            <text class="text">{{ form.others }}</text>
          </th-form-item> -->
        <!-- <th-form-item
            label="调查问卷"
            style="flex-direction: column; align-items: start"
            v-if="form.rdTaskFileEntity && form.rdTaskFileEntity.length"
          >
            <view class="info-list">
              <view class="info-list-main">
                <view class="info-list-row">
                  <view class="info-list-label">附件</view>
                  <view class="info-list-value">
                    <view style="display: flex; flex-direction: column">
                      <view
                        v-for="file in form.rdTaskFileEntity"
                        :key="file.id"
                        @click="previewFileHandle(file.fileUrl)"
                        class="info-row-item"
                      >
                        {{ file.fileName }}
                      </view>
                    </view>
                  </view>
                </view>
              </view>
            </view>
          </th-form-item> -->
        <th-form-item label="下一步任务" class="form-demandDesc" v-if="form.wayName">
          <text class="text">{{ form.wayName }}</text>
        </th-form-item>

        <th-form-item
          label="分析手段"
          v-if="form.rdSampleAnalysisEntityNext && form.rdSampleAnalysisEntityNext.length"
        >
          <text class="text">
            <view style="display: flex; flex-wrap: wrap">
              <view
                v-for="item in form.rdSampleAnalysisEntityNext"
                :key="item.id"
                class="result-tag"
                style="margin-right: 10rpx; background-color: #4d80f0"
              >
                {{ item.analysisName }}
              </view>
            </view>
          </text>
        </th-form-item>
        <view
          style="overflow: auto"
          class="table-container"
          v-if="form.rdSampleAnalysisEntityNext && form.rdSampleAnalysisEntityNext.length"
        >
          <table class="analysis-table">
            <tbody>
              <tr>
                <th style="width: 320rpx; min-width: 9.5rem">名称</th>
                <th style="width: 280rpx; min-width: 280rpx">说明</th>
              </tr>
              <tr
                align="center"
                v-for="(item, index) in form.rdSampleAnalysisEntityNext"
                :key="index"
              >
                <td>
                  <view>
                    {{ item.analysisName }}
                  </view>
                </td>
                <td>
                  <view>
                    {{ item.analysisDesc }}
                  </view>
                </td>
              </tr>
            </tbody>
          </table>
        </view>

        <th-form-item label="评审状态">
          <text class="text">
            <view v-if="form.rdFlag == '1'" class="result-tag">通过</view>
            <view v-else-if="form.rdFlag == '0'" class="result-tag" style="background-color: #f50">
              不通过
            </view>
          </text>
        </th-form-item>
        <th-form-item label="评审意见" class="form-demandDesc">
          <text class="text">{{ form.requirements }}</text>
        </th-form-item>
        <th-form-item label="回复" class="form-demandDesc" v-if="form.reply">
          <text class="text">{{ form.reply }}</text>
        </th-form-item>
        <!-- </th-form> -->
      </th-card>

      <!-- <th-card :title="form.projectName" v-if="form.taskType == 30">
          <directSampleForm ref="directSampleFormRef"></directSampleForm>
        </th-card> -->

      <template v-if="form.taskType == 30">
        <directSampleForm ref="directSampleFormRef"></directSampleForm>
      </template>

      <th-card :title="form.projectName" v-if="form.taskType == 9">
        <otherForm ref="otherFormRef"></otherForm>
      </th-card>

      <!-- <th-card :title="form.projectName" v-if="form.taskType == 4">
        <questionForm ref="questionFormRef"></questionForm>
      </th-card> -->

      <th-card
        :title="form.projectName"
        v-if="
          (form.taskType == 2 || form.taskType == 12) &&
          form.rdSampleAnalysisEntity &&
          form.rdSampleAnalysisEntity.length
        "
      >
        <th-form-item
          label="分析手段"
          v-if="form.rdSampleAnalysisEntity && form.rdSampleAnalysisEntity.length"
        >
          <text class="text">
            <view style="display: flex; flex-wrap: wrap">
              <view
                v-for="item in form.rdSampleAnalysisEntity"
                :key="item.id"
                class="result-tag"
                style="margin-right: 10rpx; background-color: #4d80f0"
              >
                {{ item.analysisName }}
              </view>
            </view>
          </text>
        </th-form-item>
        <view
          style="overflow: auto"
          class="table-container"
          v-if="form.rdSampleAnalysisEntity && form.rdSampleAnalysisEntity.length"
        >
          <table class="analysis-table">
            <tbody>
              <tr>
                <th style="width: 320rpx; min-width: 9.5rem">名称</th>
                <th style="width: 280rpx; min-width: 280rpx">说明</th>
              </tr>
              <tr align="center" v-for="(item, index) in form.rdSampleAnalysisEntity" :key="index">
                <td>
                  <view>
                    {{ item.analysisName }}
                  </view>
                </td>
                <td>
                  <view>
                    {{ item.analysisDesc }}
                  </view>
                </td>
              </tr>
            </tbody>
          </table>
        </view>
        <!-- <th-card title="外来样报检报告">
            <assayReport :pid="form.id" :version="1"></assayReport>
          </th-card> -->
      </th-card>
      <th-card :title="form.projectName" v-if="form.taskType == 13">
        <extendenWarrantyPeriodForm
          ref="extendenWarrantyPeriodFormRef"
        ></extendenWarrantyPeriodForm>
      </th-card>
      <th-card title="附件" v-if="form.rdTaskFileEntity && form.rdTaskFileEntity.length">
        <view class="info-list">
          <view class="info-list-main">
            <view class="info-list-row">
              <!-- <view class="info-list-label">附件</view> -->
              <view class="info-list-value">
                <view style="display: flex; flex-direction: column">
                  <view
                    v-for="file in form.rdTaskFileEntity"
                    :key="file.id"
                    @click="previewFileHandle(file.fileUrl)"
                    class="info-row-item"
                  >
                    {{ file.fileName }}
                  </view>
                </view>
              </view>
            </view>
          </view>
        </view>
      </th-card>
      <template v-if="form.taskType == 2 || form.taskType == 12">
        <assayReport :pid="form.id" :version="1"></assayReport>
      </template>

      <!-- <th-card :title="form.projectName" v-if="form.taskType == 3">
          <information ref="informationRef"></information>
        </th-card> -->

      <template v-if="form.taskType == 3">
        <information ref="informationRef"></information>
      </template>

      <th-card title="需求指标" v-if="isShowCheckTarget">
        <view style="overflow: auto" class="table-container">
          <table class="analysis-table">
            <tbody>
              <tr>
                <th style="width: 320rpx; min-width: 9.5rem">检验指标名称</th>
                <th style="width: 280rpx; min-width: 280rpx">U8指标</th>
                <th style="width: 280rpx; min-width: 280rpx">客户指标</th>
              </tr>
              <tr align="center" v-for="(item, index) in checkTargetList" :key="index">
                <td>
                  <view>
                    {{ item.cchkguidename }}
                  </view>
                </td>
                <td>
                  <view>
                    {{ item.checktarget }}
                  </view>
                </td>
                <td>
                  <view>
                    {{ item.cusCheckTarget }}
                  </view>
                </td>
              </tr>
            </tbody>
          </table>
        </view>
      </th-card>

      <th-card title="资料收集" v-if="isShowNewProduct">
        <view class="info-list">
          <view v-for="item in form.rdInformationDTO" :key="item.id" class="info-list-main">
            <view class="info-list-row">
              <view class="info-list-label">资料名称</view>
              <view class="info-list-value">{{ item.informationName }}</view>
            </view>
            <view class="info-list-row">
              <view class="info-list-label">资料描述</view>
              <view class="info-list-value">{{ item.informationDesc }}</view>
            </view>
            <view
              class="info-list-row"
              v-if="item.rdInformationProfileEntity && item.rdInformationProfileEntity.length"
            >
              <view class="info-list-label">附件</view>
              <view class="info-list-value">
                <view style="display: flex; flex-direction: column">
                  <view
                    v-for="file in item.rdInformationProfileEntity"
                    :key="file.id"
                    @click="previewFileHandle(file.profileUrl)"
                    class="info-row-item"
                  >
                    {{ file.profileInfo }}
                  </view>
                </view>
              </view>
            </view>
            <view class="info-list-row" v-if="item.informationWeb">
              <view class="info-list-label">网址</view>
              <view class="info-list-value info-row-item" @click="previewWeb(item.informationWeb)">
                {{ item.informationWeb }}
              </view>
            </view>
          </view>
        </view>
      </th-card>

      <th-card title="分析手段" v-if="isShowAnalysis">
        <text class="text">
          <view style="display: flex; flex-wrap: wrap">
            <view
              v-for="item in form.rdSampleAnalysisEntity"
              :key="item.id"
              class="result-tag"
              style="margin-right: 10rpx; background-color: #4d80f0"
            >
              {{ item.analysisName }}
            </view>
          </view>
        </text>
        <view style="overflow: auto" class="table-container">
          <table class="analysis-table">
            <tbody>
              <tr>
                <th style="width: 320rpx; min-width: 9.5rem">名称</th>
                <th style="width: 280rpx; min-width: 280rpx">说明</th>
              </tr>
              <tr align="center" v-for="(item, index) in form.rdSampleAnalysisEntity" :key="index">
                <td>
                  <view>
                    {{ item.analysisName }}
                  </view>
                </td>
                <td>
                  <view>
                    {{ item.analysisDesc }}
                  </view>
                </td>
              </tr>
            </tbody>
          </table>
        </view>
      </th-card>

      <th-card title="合成路线" v-if="isShowCarf">
        <view class="info-list">
          <view v-for="item in form.rdCraftEntity" :key="item.id" class="info-list-main">
            <view class="info-list-row">
              <view class="info-list-label">名称</view>
              <view class="info-list-value">{{ item.craftName }}</view>
            </view>

            <view class="info-list-row">
              <view class="info-list-label">反应条件</view>
              <view class="info-list-value">{{ item.craftDesc }}</view>
            </view>

            <view class="info-list-row">
              <view class="info-list-label">路线</view>
              <view class="info-list-value">
                <!-- <image
                      class="craft-row-img"
                      :src="item.craftUrl"
                      mode="scaleToFill"
                      @click="previewFileHandle(item.craftUrl)"
                    /> -->
                <wd-img
                  :width="140"
                  :height="140"
                  :src="item.craftUrl"
                  mode="aspectFit"
                  :enable-preview="true"
                />
              </view>
            </view>

            <view class="info-list-row">
              <view class="info-list-label">是否选择</view>
              <view class="info-list-value">
                <wd-switch
                  disabled
                  v-model="item.isUse"
                  :active-value="1"
                  :inactive-value="0"
                  style="margin: 5rpx 0"
                  size="small"
                ></wd-switch>
              </view>
            </view>
          </view>
        </view>
      </th-card>

      <th-card title="调查问卷" v-if="isQuestion">
        <view class="info-list">
          <view class="info-list-main">
            <view class="info-list-row">
              <view class="info-list-label">附件</view>
              <view class="info-list-value">
                <view style="display: flex; flex-direction: column">
                  <view
                    v-for="file in form.rdTaskFileEntity"
                    :key="file.id"
                    @click="previewFileHandle(file.fileUrl)"
                    class="info-row-item"
                  >
                    {{ file.fileName }}
                  </view>
                </view>
              </view>
            </view>
          </view>
        </view>
      </th-card>
      <th-card
        title="评审意见"
        v-if="form.reviewColor == '1' && form.reviewStatus != 2 && form.taskAllStatus == 1"
      >
        <view class="pinsghen" style="width: 100%">
          <view
            style="overflow: auto"
            class="table-container"
            v-if="opinionList && opinionList.length"
          >
            <table class="analysis-table">
              <tbody>
                <tr>
                  <th style="width: 100rpx; min-width: 100rpx">姓名</th>
                  <th style="width: 280rpx; min-width: 280rpx">评审意见</th>
                </tr>
                <tr align="center" v-for="(item, index) in opinionList" :key="index">
                  <td>
                    <view>
                      {{ item.createName }}
                    </view>
                  </td>
                  <td>
                    <view>
                      {{ item.reviewOpinion }}
                    </view>
                  </td>
                </tr>
              </tbody>
            </table>
          </view>
          <view>
            <wd-textarea
              v-model="opinionParasm.reviewOpinion"
              placeholder="请填写评审意见"
              auto-height
              :maxlength="2000"
              no-border
              style="min-height: 200rpx"
              prop="reviewOpinion"
              :disabled="!(form.reviewStatus != 2 && form.taskAllStatus == 1)"
            />
          </view>
        </view>
        <wd-button
          :round="false"
          style="width: 100%; margin-top: 20rpx"
          @click="saveDemandOpinion"
          v-if="form.reviewStatus != 2 && form.taskAllStatus == 1"
        >
          保存
        </wd-button>
      </th-card>

      <th-card
        title="审核信息"
        v-if="form.status == '1' || form.status == '2' || form.status == '3'"
      >
        <view class="row-list">
          <view
            class="row"
            v-if="
              form.id &&
              form.taskId &&
              checkPremiss('need_task_complete') &&
              form.taskAllStatus == '1'
            "
          >
            <!-- <view class="label">审核意见</view> -->
            <view class="value">
              <view class="mb2 mt2">
                <h5>审核意见</h5>
              </view>
              <wd-textarea
                type="textarea"
                v-model="comment"
                rows="6"
                placeholder="请输入审核意见"
                style="border: 1px solid #f7f7f7"
              ></wd-textarea>
            </view>
          </view>
          <view>
            <!-- <view class="mb2 mt2">
                  <h5>流转详情</h5>
                </view> -->
            <!-- <flowDetailsTable
                ref="flowDetailsTableRef"
                :processInstanceId="form.instanceId"
              ></flowDetailsTable> -->
            <flowTable ref="flowDetailsTableRef" :processInstanceId="form.instanceId"></flowTable>
          </view>
        </view>
      </th-card>
      <th-card
        title="指定任务人员"
        v-if="
          checkPremiss('rdtask_project_user') &&
          form &&
          (form.taskAllStatus == '1' || form.taskAllStatus == '0')
        "
      >
        <taskPerson
          :from="form.taskType == 9 ? '' : 'taskPerson'"
          ref="taskPersonRef"
          @refreshDetail="goBack"
        ></taskPerson>
      </th-card>
      <th-card title="评审" v-if="form.reviewColor == '1'">
        <reviews
          ref="reviewRef"
          @signComputed="saveDemandOpinion"
          @refreshDetail="init({ id: currentId })"
        ></reviews>
      </th-card>
    </view>
    <view class="flow-btn-fixed" v-if="form.taskAllStatus == '1'">
      <view class="btn_group" style="width: 100%">
        <view
          class="btn danger"
          @click="oncomplete(1)"
          v-if="form.id && form.taskId && checkPremiss('need_task_complete')"
        >
          <image src="../../../static/reject.png" class="btn-icon"></image>
          拒绝
        </view>
        <view
          class="btn primary"
          @click="oncomplete(0)"
          v-if="form.id && form.taskId && checkPremiss('need_task_complete')"
        >
          <image src="../../../static/tongyi.png" class="btn-icon"></image>
          同意
        </view>
        <view
          class="btn primary"
          @click="onRevokeShow()"
          v-if="
            !(form.taskId || !(form.id && form.status == 1)) && checkPremiss('need_task_revoke')
          "
        >
          <image src="../../../static/rovoke.png" class="btn-icon"></image>
          撤回
        </view>
        <view
          class="btn primary"
          @click="onCancelApprover()"
          v-if="
            (form.status == '2' || form.status == '3') &&
            isCanCancelApprover &&
            form.taskAllStatus == '1'
          "
        >
          <image src="../../../static/rovoke1.png" class="btn-icon"></image>
          弃审
        </view>
      </view>
    </view>
    <wd-popup v-model="revokeShow" position="bottom" @close="handleClose">
      <view style="display: flex; flex-direction: column; height: 100%">
        <wd-textarea
          v-model="revokeComment"
          placeholder="请填写撤回原因"
          no-border
          prop="revokeComment"
          class="reovke-textarea"
        />
        <view class="flow-btn-fixed">
          <view class="btn_group" style="width: 100%">
            <view class="btn danger" @click="handleClose">取消</view>
            <view class="btn primary" @click="onRevoke">撤回</view>
          </view>
        </view>
      </view>
    </wd-popup>
  </view>
</template>

<script lang="ts" setup>
import { useSetting } from '@/stores/setting';
import { getObj, completeTask, revokeProcess, reviveProcess } from '@/service/pm-task';
import {
  listLastNodePerson,
  selectTaskByProcessInstanceId,
  selectrdDocumentsPostDict,
  saveOpinion,
  updateOpinion,
  getOpinion,
} from '@/service/pm-requirement';

import { formatByDayjs } from '@/utils/util';
import { useUserStore } from '@/stores/user';
import information from '@/pages/pm/task/component/information.vue';
import sampleAnalysisze from '@/pages/pm/task/component/sample-analysize.vue';
import questionForm from '@/pages/pm/task/component/question.vue';
import taskPerson from './task-person.vue';
import reviews from './component/review.vue';
import otherForm from '@/pages/pm/task/component/other.vue';

import attenuationForm from '@/pages/pm/task/component/attenuation.vue';
import directSampleForm from '@/pages/pm/task/component/direct-sample.vue';
import extendenWarrantyPeriodForm from '@/pages/pm/task/component/extenden-warranty-period-form.vue';
// import assayReport from '@/pages/pm/assay-report/component/assayReport.vue';
import assayReport from '@/pages/pm/task/component/assayReport.vue';
const taskPersonRef = ref(null);
const reviewRef = ref(null);
const setting = useSetting();
const userStore = useUserStore();
const isShowNewProduct = ref(false);
const isShowAnalysis = ref(false);
const isShowCarf = ref(false);
const isQuestion = ref(false);
const flowDetailsTableRef: any = ref(null);
const rdProjectUserList = ref([]); // 签名列表
const otherFormRef = ref(null);
const extendenWarrantyPeriodFormRef = ref(null);
// const questionFormRef = ref(null);

let showCommonMore = ref(false);
// 提交表单数据
const form = reactive({
  id: null,
  demandDate: null,
  personName: null,
  demandType: null,
  deptHead: null,
  deptCode: null,
  applicationType: null,
  samplesNum: null,
  demandDesc: null,
  sampleCoding: null,
  askCompleteTime: null,
  taskCode: null,
  userCode: null,
  invName: null,
  invDemand: null,
  sampleFlag: null,
  demandCode: null,
  cusName: null,
  personCode: null,
  deptHeadCode: null,
  cusFlag: '0',
  demandResult: null,
  completeTime: null,
  // technologyHead: null,
  remark: null,
  // technologyHeadCode: null,
  taskId: null,
  instanceId: null,
  invStd: null,
  sampleCode: null,
  sampleBatch: null,
  deptName: null,
  rdFlag: null,
  chiefEngineer: null,
  deputyChiefEngineer: null,
  status: null,
  sampleFlagName: null,
  deputyChiefEngineerUrl: null,
  chiefEngineerUrl: null,
  sampleUnit: null,
  cusCode: null,
  projectCode: null,
  projectName: null,
  rdProjectUser: null,
  projectHead: null,
  userTime: null,
  // technologyHeadName: null,
  rdInformationDTO: [],
  rdCraftEntity: [],
  rdSampleAnalysisEntity: [],
  rdPlan: null,
  sampleReviewConclusion: null,
  requirements: null,
  projectHeadName: null,
  signedName: null,
  rdProjectUserEntity: [],
  rdTaskListAll: [],
  rdTaskFileEntity: [],
  others: null,
  wayName: null,
  rdSampleAnalysisEntityNext: [],
  taskType: null,
  reply: '',
  requestFlag: '0',
  requestNum: '',
  requestNumUnit: '',
  rdDemandFileEntity: [],
  rdDemandEntity: {},
});
const checkPremiss = (k) => {
  return userStore.userInfos.authBtnList.some((v: string) => v === k);
};
const checkTargetList = ref([]);
const isShowCheckTarget = ref(false);
const directSampleFormRef = ref(null);
const init = (params) => {
  uni.showLoading({
    mask: true,
  });
  selectrdDocumentsPostDictList();
  getObj(params)
    .then((res) => {
      form.instanceId = '';
      let samplePurpose = [],
        samplePurposeReal = [];
      if (res.data?.rdDemandEntity?.samplePurpose) {
        if (Array.isArray(res.data.rdDemandEntity.samplePurpose)) {
          samplePurpose = res.data.rdDemandEntity.samplePurpose;
        } else {
          samplePurpose = res.data.rdDemandEntity.samplePurpose.split(',');
        }
        res.data.samplePurposeDesc = '';
        samplePurpose
          .filter((item) => item)
          .map((item) => {
            if (item == '降低成本' || item == '质量优化' || item == '开发新产品') {
              samplePurposeReal.push(item);
            } else {
              samplePurposeReal.push('其他');
              res.data.samplePurposeDesc = item;
            }
          });
        res.data.rdDemandEntity.samplePurpose = samplePurposeReal.join(',');
        console.log(res.data.samplePurpose, ' res.data.samplePurpose');
      }

      Object.assign(form, res.data);
      const rdDemandEntity = res.data.rdDemandEntity;

      if (res.data.rdDemandStandard && res.data.rdDemandStandard.length) {
        isShowCheckTarget.value = true;

        checkTargetList.value = res.data.rdDemandStandard.map((item) => {
          return {
            ...item,
            cchkguidename: item.standardName,
            cchkguidecode: item.standardCode,
            checktarget: item.standardValue,
            cusCheckTarget: item.standardValuePm,
          };
        });

        checkTargetList.value = checkTargetList.value.filter((item) => item.delFlag != 1);
      } else {
        isShowCheckTarget.value = false;
        checkTargetList.value = [];
      }
      if (rdDemandEntity) {
        console.log('res', res);
        const o: any = {};
        o.demandDate = rdDemandEntity.demandDate ? formatByDayjs(rdDemandEntity.demandDate) : '';
        o.askCompleteTime = rdDemandEntity.askCompleteTime
          ? formatByDayjs(rdDemandEntity.askCompleteTime)
          : '';
        o.demandCode = rdDemandEntity.demandCode;
        o.cusCode = rdDemandEntity.cusCode;
        o.deptName = rdDemandEntity.deptName;
        o.demandType = rdDemandEntity.demandType;
        o.deptCode = rdDemandEntity.deptCode;
        o.invName = rdDemandEntity.invName;
        o.invStd = rdDemandEntity.invStd;
        o.applicationType = rdDemandEntity.applicationType;
        o.invDemand = rdDemandEntity.invDemand;
        o.sampleFlagName = rdDemandEntity.sampleFlagName;
        o.sampleCode = rdDemandEntity.sampleCode;
        o.samplesNum = rdDemandEntity.samplesNum;
        o.sampleUnit = rdDemandEntity.sampleUnit;
        o.sampleBatch = rdDemandEntity.sampleBatch;
        // o.askCompleteTime = rdDemandEntity.askCompleteTime;
        o.demandDesc = rdDemandEntity.demandDesc;
        o.cusFlag = rdDemandEntity.cusFlag;
        o.sampleFlag = rdDemandEntity.sampleFlag;
        o.personName = rdDemandEntity.personName;
        o.requestFlag = rdDemandEntity.requestFlag;
        // o.requestNum = rdDemandEntity.requestNum;
        // o.requestNumUnit = rdDemandEntity.requestNumUnit;
        // o.demandResult = rdDemandEntity.demandResult;
        // o.wayName = rdDemandEntity.wayName;

        Object.assign(form, o);
      }
      if (!form.rdTaskListAll) {
        form.rdTaskListAll = [];
      }
      isShowNewProduct.value = false;
      isShowCarf.value = false;
      isQuestion.value = false;
      isShowAnalysis.value = false;
      // analysisList.value = res.data.rdSampleAnalysisEntity;
      // const rdProject = [];
      const rdProject = [];
      if (res.data.rdProjectUserEntity) {
        res.data.rdProjectUserEntity.forEach((item: any) => {
          rdProject.push(item.userName);
        });
        form.rdProjectUser = rdProject.join(',');
      }
      try {
        const reviewWayCodeList = res.data.wayCode ? res.data.wayCode.split(',') : [];
        if (
          reviewWayCodeList.includes('31') ||
          reviewWayCodeList.includes('32') ||
          reviewWayCodeList.includes('33')
        ) {
          reviewWayCodeList.value.push('3');
        }
        if (
          reviewWayCodeList.includes('1') &&
          res.data.rdInformationDTO &&
          res.data.rdInformationDTO.length
        ) {
          isShowNewProduct.value = true;
        } else {
          isShowNewProduct.value = false;
        }

        if (
          reviewWayCodeList.includes('2') &&
          res.data.rdSampleAnalysisEntity &&
          res.data.rdSampleAnalysisEntity.length
        ) {
          isShowAnalysis.value = true;

          //获取最新版本的
          const version = res.data.version;
          if (version.length > 0) {
            const v = version[0]['version'];
            form.rdSampleAnalysisEntity = res.data.rdSampleAnalysisEntity.filter(
              (item) => item.version == v,
            );
          }
        } else {
          isShowAnalysis.value = false;
        }

        if (
          reviewWayCodeList.includes('3') &&
          res.data.rdCraftEntity &&
          res.data.rdCraftEntity.length
        ) {
          isShowCarf.value = true;
        } else {
          isShowCarf.value = false;
        }

        if (
          reviewWayCodeList.includes('4') &&
          res.data.rdTaskFileEntity &&
          res.data.rdTaskFileEntity.length
        ) {
          isQuestion.value = true;
        } else {
          isQuestion.value = false;
        }
      } catch (error) {}

      let rdInformationDTO = res.data.rdInformationDTO || [];
      rdInformationDTO = rdInformationDTO.map((item) => {
        const l = item.rdInformationProfileEntity;
        const rdInformationProfileEntity = [];
        l.forEach((rd) => {
          const profileType = rd.profileType;
          if (profileType == 'web') {
            item.informationWeb = rd.profileUrl;
          } else {
            rdInformationProfileEntity.push(rd);
          }
        });

        return {
          ...item,
          rdInformationProfileEntity: rdInformationProfileEntity,
        };
      });

      form.rdInformationDTO = rdInformationDTO;

      // getCancelApprover();
      if (res.data.instanceId) {
        selectTaskByProcessInstanceId({
          processInstanceId: res.data.instanceId,
        })
          .then((res) => {
            form.taskId = res.data && res.data.taskId ? res.data.taskId : null;
          })
          .catch(() => {
            form.taskId = null;
          });
        getCancelApprover();
        console.log('form', form);
      }
      nextTick(() => {
        flowDetailsTableRef.value?.getFlowDetails();
        // if (form.assignColor == '1') {
        try {
          taskPersonRef.value?.init({
            id: form.id,
            taskCode: form.taskCode,
            demandCode: form.demandCode,
          });
          directSampleFormRef.value?.init(form);
          otherFormRef.value?.init(form);
          // questionFormRef.value?.init(form);
          extendenWarrantyPeriodFormRef.value?.init(form);
        } catch (error) {}

        // }
        if (form.reviewColor == '1') {
          reviewRef.value.init(form);
          // reviewRef.value.init({
          //   id: form.id,
          //   taskCode: form.taskCode,
          //   demandCode: form.demandCode,
          // });
        }
      });

      const v = String(res.data.taskType);
      taskTypeList.value = [v];

      form.rdTaskListAll = form.rdTaskListAll.map((item) => {
        return {
          ...item,
          title: `${item.taskCode} - ${item.projectName}`,
        };
      });

      if (form.reviewColor == '1') {
        rdReviewOpinionHandle();
      }
      setTimeout(() => {
        uni.hideLoading();
      }, 300);
    })
    .catch(() => {
      uni.hideLoading();
    })
    .finally(() => {
      uni.stopPullDownRefresh();
    });
};

const currentId = ref('');
onLoad((options) => {
  const { id } = options;
  currentId.value = id;
  init({
    id: id,
  });
});

const getRdFlat = (flag) => {
  if (flag == '1') {
    return '通过';
  } else if (flag == '0') {
    return '不通过';
  }
};

onPullDownRefresh(() => {
  init({
    id: form.id,
  });
});

const goBack = () => {
  uni.navigateBack();
};

const preview = (url) => {
  if (!url) return;
  uni.previewImage({
    urls: [url],
  });
};
const previewImg = (url) => {
  if (!url) return;
  const urls = [];
  urls.push(url);
  console.log('url', urls);
  uni.previewImage({
    urls: urls,
    fail: (fail) => {
      console.log('fail', fail);
    },
  });
};

const previewFileHandle = (file) => {
  uni.navigateTo({
    url: '/pages/pm/preview-online?url=' + file,
  });
};

const previewWeb = (url) => {
  uni.navigateTo({
    url: '/pages/pm/preview-online?url=' + url + '&isWeb=1',
  });
};
const opinionParasm = reactive({
  reviewOpinion: '',
  reviewType: 0,
  id: null,
});
const opinionList = ref([]);

const saveDemandOpinion = () => {
  const params = { ...opinionParasm, demandId: form.id, demandCode: form.demandCode };
  debugger;
  uni.showLoading({
    mask: true,
  });
  (opinionParasm.id ? updateOpinion(params) : saveOpinion(params))
    .then((res) => {
      if (res.code != 0) {
        uni.showToast({
          title: res.msg,
          icon: 'none',
        });
        return;
      }
      init({ id: form.id });
    })
    .finally(() => {
      uni.hideLoading();
    });
};

const rdReviewOpinionHandle = () => {
  uni.showLoading({
    mask: true,
  });
  getOpinion({
    demandCode: form.demandCode,
  })
    .then((res) => {
      if (res.code != 0) {
        uni.showToast({
          mask: true,
          title: `获取数据失败，失败原因：${res.msg}`,
          icon: 'none',
        });
        return;
      }
      opinionList.value = res.data;
      const userInfos = userStore.userInfos;
      const cusPerson = userInfos.user.username;
      const o = res.data.find((item) => item.createBy == cusPerson);
      opinionParasm.reviewOpinion = o['reviewOpinion'];
      opinionParasm.id = o['id'];
    })
    .finally(() => {
      uni.hideLoading();
    });
};
// 审核信息
const comment = ref('');
const oncomplete = (type) => {
  if (type == '1' && !comment.value) {
    uni.showToast({
      title: '请填写审核意见',
      icon: 'none',
      mask: true,
    });
    return;
  }

  const params = {
    // ...form,
    taskId: form.taskId,
    comment: comment.value,
    id: form.id,
    approve: type == 0 ? true : false,
  };
  uni.showLoading({
    mask: true,
  });
  completeTask(params, form.id)
    .then((res) => {
      if (res.code == 0) {
        uni.showToast({
          title: '单据审核成功',
          icon: 'none',
          mask: true,
        });
        // uni.navigateBack({});
        form.instanceId = '';
        init({
          id: form.id,
        });
        uni.$emit('refresh');
        // nextTick(() => {
        //   flowDetailsTableRef.value.getFlowDetails();
        // });
      } else {
        uni.showToast({
          mask: true,
          title: `单据审核失败，失败原因：${res.msg}`,
          icon: 'none',
        });
      }
    })
    .finally(() => {
      uni.hideLoading();
    });
};

// 撤回
const revokeComment = ref('');
const revokeShow = ref(false);

const onRevokeShow = () => {
  revokeShow.value = true;
};
const handleClose = () => {
  revokeShow.value = false;
};
const onRevoke = () => {
  uni.showModal({
    title: '提示',
    content: '是否撤回该单据',
    showCancel: true,
    success: ({ confirm, cancel }) => {
      if (cancel) {
        return;
      }
      uni.showLoading({
        mask: true,
      });
      revokeProcess({
        id: form.id,
        instanceId: form.instanceId,
        comment: revokeComment.value,
      })
        .then((res) => {
          if (res.code == 0) {
            uni.showToast({
              mask: true,
              title: `单据${form.demandCode}撤回成功`,
              icon: 'none',
            });
            handleClose();
            init({ id: form.id });
          } else {
            uni.showToast({
              mask: true,
              title: `单据${form.demandCode}撤回失败，失败原因：${res.msg}`,
              icon: 'none',
            });
          }
        })
        .finally(() => {
          uni.hideLoading();
        });
    },
  });
};
const scrollTop = ref(0);
const isScrolling = ref(false);
onPageScroll((e) => {
  const scroll = e.scrollTop;
  // console.log(scroll, isScrolling.value);

  // if (scrollTop.value == scroll) {
  //   isScrolling.value = true;
  //   scrollTop.value = scroll;
  // } else {
  //   isScrolling.value = false;
  // }
});

const isCanCancelApprover = ref(false); // 是否能弃审
const getCancelApprover = () => {
  listLastNodePerson({
    processInstanceId: form.instanceId,
  })
    .then((res) => {
      const dataList = res.data;
      const username = userStore.userInfos.user.username;
      if (dataList.find((item) => item == username)) {
        isCanCancelApprover.value = true;
      } else {
        isCanCancelApprover.value = false;
      }
    })
    .finally(() => {});
};

const onCancelApprover = () => {
  uni.showModal({
    title: '提示',
    content: '是否弃审该单据',
    showCancel: true,
    success: ({ confirm, cancel }) => {
      if (cancel) {
        return;
      }
      uni.showLoading({
        mask: true,
      });
      reviveProcess(form.id)
        .then((res) => {
          if (res.code == 0) {
            uni.showToast({
              mask: true,
              title: `单据${form.demandCode}弃审成功`,
              icon: 'none',
            });
            form.instanceId = '';
            init({ id: form.id });
            // nextTick(() => {
            //   flowDetailsTableRef.value.getFlowDetails();
            // });
          } else {
            uni.showToast({
              mask: true,
              title: `单据${form.demandCode}弃审失败，失败原因：${res.msg}`,
              icon: 'none',
            });
          }
        })
        .finally(() => {
          uni.hideLoading();
        });
    },
  });
};

const taskTypeList = ref([]);
const rdTaskListAllActiveKey = ref([]);

const tableRefs = ref({});
const setItemRef = (e, item) => {
  tableRefs.value[item] = e;
};

const beforeExpend = (e) => {
  return new Promise((reslove, reject) => {
    const o = form.rdTaskListAll.find((item) => item.id == e);
    try {
      uni.showLoading();
      getObj({ id: e })
        .then((res) => {
          if (res.code != 0) {
            uni.showToast({
              mask: true,
              title: `获取数据失败, 失败原因: ${res.msg}`,
              icon: 'none',
            });
            return;
          }
          nextTick(() => {
            tableRefs.value[o['taskCode']].init(res.data);
            // setTimeout(() => {
            reslove(true);
            // }, 1000);
          });
        })
        .finally(() => {
          uni.hideLoading();
        });
    } catch (error) {
      console.log('err', error);
      reject(false);
    }
  });
};

const selectrdDocumentsPostDictList = async () => {
  try {
    const res = await selectrdDocumentsPostDict({
      webSql: `documents_code = '2'`,
      size: 1000,
    });
    if (res.code !== 0) {
      return;
    }
    rdProjectUserList.value = res.data.records;
  } catch (err) {
    console.log('err', err);
  }
};

// type 0 获取姓名 1 获取签名
const getProjectName = (item, type = 0, isShow = true) => {
  console.log(form.rdProjectUserEntity, item);
  let l =
    form.rdProjectUserEntity &&
    form.rdProjectUserEntity.filter((f) => f.userType == item.documentsPostCode);
  if (isShow) {
    l =
      (form.rdProjectUserEntity &&
        form.rdProjectUserEntity.filter(
          (f) => f.userCode == item.userCode && f.userType == item.documentsPostCode,
        )) ||
      [];
  } else {
    l =
      (form.rdProjectUserEntity &&
        form.rdProjectUserEntity.filter((f) => f.userType == item.documentsPostCode)) ||
      [];
  }

  let s = '';
  if (l.length) {
    console.log('s', s);
    if (type == 0) {
      s = l.map((item) => item.userName).join(',');
      return s;
    } else {
      // s = l.map((item) => item.userUrl).join(',');
      s = l[0]['userUrl'];
      return s;
    }
  } else {
    return s;
  }
};
</script>

<style lang="scss" scoped>
@import '../experiment/components/table';

.block .content {
  padding: 0 !important;
}

.card-detail {
  padding: 0 !important;
}

.wd-cell {
  padding-left: 0 !important;
}

.wd-card__title {
  border-left: 4px solid #2e5cf6 !important;
}

.pm-table {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  padding: 0 30rpx;

  .pm-title {
    box-sizing: border-box;
    padding-left: 20rpx;
    margin: 40rpx 0;
    font-size: 32rpx;
    font-weight: bold;
    color: #333;
    border-left: 8rpx solid #2e5cf6;
    border-radius: 4rpx;
  }

  .pm-row {
    display: flex;
    min-height: 60rpx;
    border-bottom: 1px solid #f6f0f0;

    .pm-label {
      display: flex;
      align-items: center;
      width: 20%;
      font-size: 26rpx;
      color: #979494;
    }

    .pm-value {
      display: flex;
      flex: 1;
      align-items: center;
      font-size: 26rpx;
      color: #333;
    }
  }
}

.sign-main {
  // display: flex;
  // align-items: center;
  // justify-content: center;
  // width: 100%;
  // margin: 20rpx 0;
  position: fixed;
  right: 0rpx;
  bottom: 40rpx;
  width: 160rpx;
  height: 80rpx;
  line-height: 80rpx;
  color: white;
  text-align: center;
  background-color: rgb(77 128 240);

  // border-radius: 50%;
  border-top-left-radius: 40rpx;
  border-bottom-left-radius: 40rpx;
}

:deep(.label) {
  width: 160rpx !important;
}

.result-tag {
  padding: 6rpx 14rpx;
  margin: 2rpx 0;
  font-size: 24rpx;
  color: white;
  background-color: #87d068;
  border-radius: 4rpx;
}

.sign-main-show {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  .sign-main-show-title {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 80rpx;
    margin-bottom: 20rpx;
    font-size: 30rpx;
    font-weight: bold;
    color: #818181;
    border-bottom: 1px solid #e3e3e3;
  }

  .sign-main-show-line {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 90%;
    padding: 20rpx;
    margin: 20rpx 0;
    border: 4rpx solid #d0dbff;
    border-radius: 10rpx;
  }

  .sign-main-show-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 80rpx;
    border-top: 1px solid #e3e3e3;
  }
}

.info-list {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.info-list-main {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 10rpx;
  margin: 10rpx 0;
  border: 1px solid #e3e3e3;
  border-radius: 8rpx;

  .info-list-row {
    display: flex;
    width: 100%;

    .info-list-label {
      width: 150rpx;
      font-size: 28rpx;
      color: #808080;
    }

    .info-list-value {
      display: flex;
      flex: 1;
      align-items: center;
      width: 0;
    }
  }
}

.craft-row {
  display: flex;
  align-items: center;

  .craft-row-img-main {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: center;
    width: 0;
  }
}

.craft-row-img {
  width: 80rpx;
  height: 80rpx;
}

.form-demandDesc {
  align-items: flex-start !important;
}

.info-row-item {
  padding: 6rpx 0;
  word-break: break-all;

  // border-bottom: 1px solid #f2f2f2;
}

.text {
  word-break: break-all;
  word-wrap: break-word;
}

.flow-btn-fixed {
  width: 100%;
  background-color: white;
  border-top: 1px solid #f2f2f1;
}

.btn_group {
  display: flex;
  justify-content: space-between;

  // margin: 0rpx 0 20rpx;
  // border-bottom: 1px solid #f2f2f1;

  .btn {
    display: flex;

    // width: 49%;
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    // height: 40px;
    min-height: 40px;
    padding: 10rpx 0;
    font-size: 24rpx;
    color: black;

    // background-color: white !important;
    background-color: #dbecff !important;
    border-left: 1px solid #f7f7f7;
    border-radius: 0 !important;

    // color: white;
    border-radius: 6rpx;

    .btn-icon {
      width: 40rpx;
      height: 40rpx;
      margin-bottom: 8rpx;
    }
  }

  .danger {
    background-color: #f56c6c;
  }

  .primary {
    background-color: #409eff;
  }
}

:deep(.wd-navbar__left--hover) {
  background: none;
}

.task_person {
  position: fixed;
  right: 0;
  bottom: 200rpx;
  color: #fff;
  height: auto;
  width: auto;
  padding: 10rpx 20rpx;
  background: #409eff;
  border-top-left-radius: 20px;
  border-bottom-left-radius: 20px;
  transition: all 0.5s;
  &.isScrolling {
    width: 10rpx;
    height: 10rpx;
    // border-radius: 50%;
  }
}

.info_row_i {
  border-bottom: 2rpx solid #409eff;
  &:last-child {
    border-bottom: 0;
  }
}

.exportModel {
  width: 100%;
  margin-top: 10rpx;
  font-size: 28rpx;
  color: #409eff;
  text-align: center;
}

.pinsghen :deep(.wd-textarea__inner) {
  min-height: 200rpx;
}
</style>
